<?php
	//引入DH映射表
	$attr_mapping = require('attr_mapping.php');
	$tmp_arr = array();
	$sql = "
		SELECT 
		ga.goods_id,
		ga.attr_id,
		ga.attr_value,
		ga.attr_price,
		a.attr_name
		FROM ". $this->_dbPrefix. "goods_attr ga
		LEFT JOIN ". $this->_dbPrefix. "attribute a ON ga.attr_id=a.attr_id
		WHERE 
		a.attr_type IN (1,2)
		AND ga.goods_id=". $product_id;
	$rst = $this->_dbObj->getArray($sql);
	//print_r($sql);
	//exit;
	if(count($rst)>0){
		foreach($rst as $item){
			//type
			foreach($attr_mapping as $v){
				if(preg_match('/(^|,| )'.preg_quote($item['attr_name']).'(,| |$)/i', $v['keyword'])){
					$type = $v['mapping'];
					break;
				}
			}//end type

			if (!isset($type) || empty($type))
				continue;

			//组装数据
			$tmp_arr[] = array(
				'type' => $type,
				'text' => $item['attr_value'],
				'value' => $item['attr_price'],
				'status' => 0,
			); 
		}	
	}

	return $tmp_arr;
?>